<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <!-- <el-form-item label="" prop="sampleTalentInfoId">
        <el-input v-model="queryParams.sampleTalentInfoId" placeholder="达人信息表ID" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="sampleTalentCooperateId">
        <el-input v-model="queryParams.sampleTalentCooperateId" placeholder="笔记/直播合作ID" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <!-- <el-form-item label="" prop="templateId">
        <el-input v-model="queryParams.templateId" placeholder="模板ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <!-- <el-form-item label="" prop="templateSecondryId">
        <el-input v-model="queryParams.templateSecondryId" placeholder="颜色ID" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="templateSizeId">
        <el-input v-model="queryParams.templateSizeId" placeholder="尺寸ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="contactId">
        <el-input v-model="queryParams.contactId" placeholder="联系方式ID" clearable @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <el-form-item label="" prop="isReturn">
        <el-input v-model="queryParams.isReturn" placeholder="是否归还" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="onlineNumber">
        <el-input v-model="queryParams.onlineNumber" placeholder="线上订单号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="subOrderNumber">
        <el-input v-model="queryParams.subOrderNumber" placeholder="子订单编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="buyerAccount">
        <el-input v-model="queryParams.buyerAccount" placeholder="买家帐号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="paymentOrderNumber">
        <el-input v-model="queryParams.paymentOrderNumber" placeholder="支付单号" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="" prop="paymentMethod">
        <el-input v-model="queryParams.paymentMethod" placeholder="付款方式" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <el-button :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'" size="mini"
          @click="shouqi">展开/收起</el-button>
      </el-form-item>
      <div v-if="isOpen">
        <el-form-item label="" prop="freight">
          <el-input v-model="queryParams.freight" placeholder="运费" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="payableAmount">
          <el-input v-model="queryParams.payableAmount" placeholder="应付金额" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="fixedLine">
          <el-input v-model="queryParams.fixedLine" placeholder="固话" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="zipCode">
          <el-input v-model="queryParams.zipCode" placeholder="邮编" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="productCode">
          <el-input v-model="queryParams.productCode" placeholder="商品编码" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="productNum">
          <el-input v-model="queryParams.productNum" placeholder="商品数量" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="productName">
          <el-input v-model="queryParams.productName" placeholder="商品名称" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="productPricing">
          <el-input v-model="queryParams.productPricing" placeholder="商品单价" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="productCost">
          <el-input v-model="queryParams.productCost" placeholder="商品成本" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="productSettlment">
          <el-input v-model="queryParams.productSettlment" placeholder="结算金额" clearable
            @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="productBatch">
          <el-input v-model="queryParams.productBatch" placeholder="生产批次" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="manufactureDate">
          <el-date-picker clearable v-model="queryParams.manufactureDate" type="date" value-format="yyyy-MM-dd"
            placeholder="请选择生产日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="" prop="expressCompany">
          <el-input v-model="queryParams.expressCompany" placeholder="快递公司" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="expressNumber">
          <el-input v-model="queryParams.expressNumber" placeholder="快递单号" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="deliveryTime">
          <el-date-picker clearable v-model="queryParams.deliveryTime" type="date" value-format="yyyy-MM-dd"
            placeholder="请选择发货时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="" prop="salesman">
          <el-input v-model="queryParams.salesman" placeholder="业务员" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="" prop="offlineNotes">
          <el-input v-model="queryParams.offlineNotes" placeholder="便签|线下备注" clearable
            @keyup.enter.native="handleQuery" />
        </el-form-item>
      </div>
      <!-- <el-form-item label="逻辑删除;0=未删除；1=已删除" prop="isDelete">
        <el-input v-model="queryParams.isDelete" placeholder="逻辑删除;0=未删除；1=已删除" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item> -->

    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['product:sampleApply:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['product:sampleApply:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['product:sampleApply:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['product:sampleApply:export']">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-plus" @click="chatReturn">发起退货</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-plus" @click="ToDo">待办</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button size="mini" plain icon="el-icon-plus" @click="ToDoCheck">审批</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="sampleApplyList" @selection-change="handleSelectionChange" @row-dblclick="t">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="ID" align="center" prop="id" />
      <!-- <el-table-column label="达人信息表ID" align="center" prop="sampleTalentInfoId" />
      <el-table-column label="笔记/直播合作ID" align="center" prop="sampleTalentCooperateId" /> -->
      <!-- ，笔记=note;直播=live -->
      <el-table-column label="合作类型" align="center" prop="sampleTalentCooperateType">
        <template slot-scope="scope">{{
          scope.row.sampleTalentCooperateType | state1
        }}</template>
      </el-table-column>
      <!-- <el-table-column label="模板ID" align="center" prop="templateId" /> -->
      <!-- <el-table-column label="颜色ID" align="center" prop="templateSecondryId" />
      <el-table-column label="尺寸ID" align="center" prop="templateSizeId" />
      <el-table-column label="联系方式ID" align="center" prop="contactId" width="90" /> -->
      <el-table-column label="合作款式" align="center" prop="productNo" width="110" />
      <el-table-column label="款式主图" align="center" prop="styleMainImage" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.styleMainImage" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="商品编码" align="center" prop="productCode" width="130" />
      <el-table-column label="颜色属性" align="center" prop="colorProperty" />
      <el-table-column label="尺寸" align="center" prop="size" />
      <el-table-column label="平台名称" align="center" prop="platform" />
      <el-table-column label="昵称" align="center" prop="xhsNickname" />
      <el-table-column label="电话" align="center" prop="phone" />
      <el-table-column label="收件人" align="center" prop="recipient" />
      <el-table-column label="收件人地址" align="center" prop="address" width="100" />
      <el-table-column label="固话" align="center" prop="fixedLine" />
      <el-table-column label="卖家备注" align="center" prop="remark" />
      <el-table-column label="线上订单号" align="center" prop="onlineNumber" width="130" />
      <el-table-column label="子订单编号" align="center" prop="subOrderNumber" width="130" />
      <el-table-column label="买家帐号" align="center" prop="buyerAccount" />
      <el-table-column label="支付单号" align="center" prop="paymentOrderNumber" />
      <el-table-column label="付款方式" align="center" prop="paymentMethod" />
      <el-table-column label="运费" align="center" prop="freight" />
      <el-table-column label="应付金额" align="center" prop="payableAmount" />

      <el-table-column label="邮编" align="center" prop="zipCode" />

      <el-table-column label="商品数量" align="center" prop="productNum" />
      <el-table-column label="商品名称" align="center" prop="productName" />
      <el-table-column label="商品单价" align="center" prop="productPricing" />
      <el-table-column label="商品成本" align="center" prop="productCost" />
      <el-table-column label="结算金额" align="center" prop="productSettlment" />
      <el-table-column label="生产批次" align="center" prop="productBatch" />
      <el-table-column label="生产日期" align="center" prop="manufactureDate">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.manufactureDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="快递公司" align="center" prop="expressCompany" />
      <el-table-column label="快递单号" align="center" prop="expressNumber" />
      <el-table-column label="发货时间" align="center" prop="deliveryTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.deliveryTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="业务员" align="center" prop="salesman" />
      <el-table-column label="便签|线下备注" align="center" prop="offlineNotes" />
      <el-table-column label="申请状态" align="center" prop="applyStatus" />
      <el-table-column label="退货电话" align="center" prop="returnPhone" />
      <el-table-column label="退货收件人" align="center" prop="returnRecipient" width="100" />
      <el-table-column label="退货收件人地址" align="center" prop="returnAddress" width="130" />
      <el-table-column label="退货联系方式" align="center" prop="returnContactId" width="130" />
      <el-table-column label="退货取件码" align="center" prop="returnExpressPickupCode" width="100" />
      <el-table-column label="退货订单号" align="center" prop="returnExpressNumber" width="100" />
      <el-table-column label="退货时间" align="center" prop="returnDate" />
      <el-table-column label="是否归还" align="center" prop="isReturn" />
      <!-- <el-table-column label="逻辑删除;0=未删除；1=已删除" align="center" prop="isDelete" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['product:sampleApply:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['product:sampleApply:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改样衣申请记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body v-if="open">
      <div class="el-dialog-div">
        <el-form ref="form" :model="form" :rules="rules" label-width="110px">
          <el-col :span="7">
            <!-- <el-form-item label="达人信息表ID" prop="sampleTalentInfoId">
              <el-input v-model="form.sampleTalentInfoId" placeholder="达人信息表ID" />
            </el-form-item>
            <el-form-item label="笔记/直播合作ID" prop="sampleTalentCooperateId">
              <el-input v-model="form.sampleTalentCooperateId" placeholder="笔记/直播合作ID" />
            </el-form-item> -->
            <!-- <el-form-item label="模板ID" prop="templateId">
              <el-input v-model="form.templateId" placeholder="模板ID" />
            </el-form-item> -->
            <!-- <el-form-item label="颜色ID" prop="templateSecondryId">
              <el-input v-model="form.templateSecondryId" placeholder="颜色ID" />
            </el-form-item>
            <el-form-item label="尺寸ID" prop="templateSizeId">
              <el-input v-model="form.templateSizeId" placeholder="尺寸ID" />
            </el-form-item>
            <el-form-item label="联系方式ID" prop="contactId">
              <el-input v-model="form.contactId" placeholder="联系方式ID" />
            </el-form-item> -->

            <el-form-item label="合作款式" prop="productNo">
              <!-- <el-input v-model="form.productNo" placeholder="请输入货号" /> -->
              <el-select v-model="form.productNo" clearable filterable remote :remote-method="getDatas" :loading="loading"
                placeholder="请选择合作款式">
                <el-option v-for="item in options" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="颜色属性" prop="colorProperty">
              <!-- <el-input v-model="form.colorProperty" placeholder="请输入颜色属性" :loading="loading"/> -->
              <el-select @focus="onFocus" ref="selectRef" v-model="form.colorProperty" clearable filterable remote
                :remote-method="getData" placeholder="请选择颜色属性">
                <el-option v-for="item in ColorLike" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="尺寸" prop="size">
              <el-select v-model="form.size" placeholder="请选择尺寸" clearable>
                <el-option v-for="dict in dict.type.sys_product_size" :key="dict.value" :label="dict.label"
                  :value="dict.value" />
              </el-select>
            </el-form-item>
            <el-form-item label="卖家备注" prop="remark">
              <el-input v-model="form.remark" placeholder="卖家备注" />
            </el-form-item>
            <el-form-item label="线上订单号" prop="onlineNumber">
              <el-input v-model="form.onlineNumber" placeholder="线上订单号" />
            </el-form-item>
            <el-form-item label="子订单编号" prop="subOrderNumber">
              <el-input v-model="form.subOrderNumber" placeholder="子订单编号" />
            </el-form-item>
            <el-form-item label="买家帐号" prop="buyerAccount">
              <el-input v-model="form.buyerAccount" placeholder="买家帐号" />
            </el-form-item>
            <el-form-item label="支付单号" prop="paymentOrderNumber">
              <el-input v-model="form.paymentOrderNumber" placeholder="支付单号" />
            </el-form-item>
            <el-form-item label="付款方式" prop="paymentMethod">
              <el-input v-model="form.paymentMethod" placeholder="付款方式" />
            </el-form-item>
            <el-form-item label="运费" prop="freight">
              <el-input v-model="form.freight" placeholder="运费" />
            </el-form-item>
            <el-form-item label="应付金额" prop="payableAmount">
              <el-input v-model="form.payableAmount" placeholder="应付金额" />
            </el-form-item>

          </el-col>
          <el-col :span="1">
            <el-form-item></el-form-item>
          </el-col>
          <el-col :span="7">
            <!-- <el-form-item label="款式主图" prop="styleMainImage">
              <image-upload v-model="form.styleMainImage" />
            </el-form-item> -->
            <!-- <el-form-item label="商品编码" prop="productCode">
              <el-input v-model="form.productCode" placeholder="商品编码" />
            </el-form-item> -->

            <el-form-item label="商品数量" prop="productNum">
              <el-input v-model="form.productNum" placeholder="商品数量" />
            </el-form-item>
            <el-form-item label="商品名称" prop="productName">
              <el-input v-model="form.productName" placeholder="商品名称" />
            </el-form-item>
            <el-form-item label="商品单价" prop="productPricing">
              <el-input v-model="form.productPricing" placeholder="商品单价" />
            </el-form-item>
            <el-form-item label="商品成本" prop="productCost">
              <el-input v-model="form.productCost" placeholder="商品成本" />
            </el-form-item>
            <el-form-item label="结算金额" prop="productSettlment">
              <el-input v-model="form.productSettlment" placeholder="结算金额" />
            </el-form-item>
            <el-form-item label="生产批次" prop="productBatch">
              <el-input v-model="form.productBatch" placeholder="生产批次" />
            </el-form-item>
            <el-form-item label="生产日期" prop="manufactureDate">
              <el-date-picker clearable v-model="form.manufactureDate" type="date" value-format="yyyy-MM-dd"
                placeholder="请选择生产日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="快递公司" prop="expressCompany">
              <el-input v-model="form.expressCompany" placeholder="快递公司" />
            </el-form-item>
            <el-form-item label="快递单号" prop="expressNumber">
              <el-input v-model="form.expressNumber" placeholder="快递单号" />
            </el-form-item>
            <el-form-item label="发货时间" prop="deliveryTime">
              <el-date-picker clearable v-model="form.deliveryTime" type="date" value-format="yyyy-MM-dd"
                placeholder="请选择发货时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="业务员" prop="salesman">
              <el-input v-model="form.salesman" placeholder="业务员" />
            </el-form-item>

            <!-- <el-form-item label="逻辑删除;0=未删除；1=已删除" prop="isDelete">
          <el-input v-model="form.isDelete" placeholder="逻辑删除;0=未删除；1=已删除" />
        </el-form-item> -->
          </el-col>
          <el-col :span="1">
            <el-form-item></el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="是否归还" prop="isReturn">
              <el-input v-model="form.isReturn" placeholder="是否归还" />
            </el-form-item>
            <el-form-item label="便签|线下备注" prop="offlineNotes">
              <el-input v-model="form.offlineNotes" placeholder="便签|线下备注" />
            </el-form-item>
            <el-form-item label="固话" prop="fixedLine">
              <el-input v-model="form.fixedLine" placeholder="固话" />
            </el-form-item>
            <el-form-item label="邮编" prop="zipCode">
              <el-input v-model="form.zipCode" placeholder="邮编" />
            </el-form-item>
            <el-form-item label="退货电话" prop="returnPhone">
              <el-input v-model="form.returnPhone" placeholder="退货电话" />
            </el-form-item>
            <el-form-item label="退货收件人" prop="returnRecipient">
              <el-input v-model="form.returnRecipient" placeholder="退货收件人" />
            </el-form-item>
            <el-form-item label="退货收件人地址" prop="returnAddress">
              <el-input v-model="form.returnAddress" placeholder="退货收件人地址" />
            </el-form-item>
            <el-form-item label="退货联系方式" prop="returnContactId">
              <el-input v-model="form.returnContactId" placeholder="退货联系方式" />
            </el-form-item>
            <el-form-item label="退货取件码" prop="returnExpressPickupCode">
              <el-input v-model="form.returnExpressPickupCode" placeholder="退货取件码" />
            </el-form-item>
            <el-form-item label="退货订单号" prop="returnExpressNumber">
              <el-input v-model="form.returnExpressNumber" placeholder="退货订单号" />
            </el-form-item>
            <el-form-item label="退货时间" prop="returnDate">
              <el-date-picker clearable v-model="form.returnDate" type="date" value-format="yyyy-MM-dd"
                placeholder="请选择退货时间">
              </el-date-picker>
            </el-form-item>

          </el-col>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>

    </el-dialog>

    <el-dialog :visible.sync="VisibleCheck" append-to-body title="审批" width="500px" v-if="VisibleCheck">

      <el-form ref="formCheck" :model="formCheck" :rules="rules" label-width="100px">
        <el-form-item label="是否同意" prop="isAgree">
          <!-- <el-input v-model="formCheck.isAgree" placeholder="是否同意" /> -->
          <!-- <el-button type="primary" @click="submitTrue">确 定</el-button>
        <el-button @click="submitFalse">取 消</el-button> -->
          <el-radio-group v-model="formCheck.isInsured" size="small" fill="#66b1ff">
            <el-radio :label="'true'">同意</el-radio>
            <el-radio :label="'false'">不同意</el-radio>
            <!-- <el-radio :label="null">所有</el-radio> -->
          </el-radio-group>
        </el-form-item>
        <el-form-item label="截图" prop=" checkPic">
          <el-input v-model="formCheck.checkPic" placeholder="截图" />
        </el-form-item>
        <el-form-item label="审核理由" prop="reason">
          <el-input v-model="formCheck.reason" placeholder="审核理由" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="formCheck.remark" placeholder="备注" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 50px;">
        <el-button type="primary" @click="submitCheck">确 定</el-button>

        <el-button @click="cancelCheck">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listSecondry, getSecondry, delSecondry, addSecondry, updateSecondry, getInfoByName, productNoColorLike } from "@/api/product/secondry";
import { listTemplate, getTemplate, delTemplate, addTemplate, updateTemplate, addTemplateAndSecondry, addProNoColorSize, productNoLike } from "@/api/product/template";
import { listSampleApply, getSampleApply, delSampleApply, addSampleApply, updateSampleApply, addApply, returnApply, selectSampleTalentApplyToDo, SampleTalentApplyCheck } from "@/api/sample/sampleApply";
//--------导入token
import { getToken } from "@/utils/auth";
export default {
  name: "SampleApply",
  dicts: ['sys_product_qudao', 'sys_one_zero', 'sys_product_size'],
  data() {
    return {
      VisibleCheck: false,
      formCheck: {},
      //选中get
      returnAddress: [],
      list: [],
      //模糊匹配
      ColorLike: [],
      options: [], // 选项，从后端传递过来
      //搜索栏展示和收起
      isOpen: false,
      filePay: [],
      pjtUrl: process.env.VUE_APP_BASE_API,
      // 图片数量限制
      limit: 2,
      imgUpload: {
        // 设置上传的请求头部
        headers: {
          Authorization: "Bearer " + getToken()
        },
        // 图片上传的方法地址:
        url: process.env.VUE_APP_BASE_API + "/common/upload",
      },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 样衣申请记录表格数据
      sampleApplyList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        sampleTalentInfoId: null,
        sampleTalentCooperateId: null,
        sampleTalentCooperateType: null,
        templateId: null,
        templateSecondryId: null,
        templateSizeId: null,
        contactId: null,
        isReturn: null,
        onlineNumber: null,
        subOrderNumber: null,
        buyerAccount: null,
        paymentOrderNumber: null,
        paymentMethod: null,
        freight: null,
        payableAmount: null,
        fixedLine: null,
        zipCode: null,
        styleMainImage: null,
        productCode: null,
        productNum: null,
        productName: null,
        productPricing: null,
        productCost: null,
        productSettlment: null,
        productBatch: null,
        manufactureDate: null,
        expressCompany: null,
        expressNumber: null,
        deliveryTime: null,
        salesman: null,
        offlineNotes: null,
        applyStatus: null,
        isDelete: null,
        returnPhone: null,
        returnRecipient: null,
        returnAddress: null,
        returnContactId: null,
        returnExpressPickupCode: null,
        returnExpressNumber: null,
        returnDate: null,



      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        sampleTalentInfoId: [
          { required: true, message: "达人信息表ID不能为空", trigger: "blur" }
        ],
        sampleTalentCooperateId: [
          { required: true, message: "笔记/直播合作ID不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    if (this.$route.query.id) {
      this.$set(this.queryParams, "sampleTalentInfoId", this.$route.query.id);
    }
    this.getList();
  },
  filters: {
    state1(string) {
      if (string == 'note') { return "笔记" };
      if (string == 'live') { return "直播" };
      if (string == 'VFU') { return "VFU" };
      // if (int == 2) { return "审批通过" };
    },
  },
  methods: {
    ToDo() {
      selectSampleTalentApplyToDo().then(res => {
        this.sampleApplyList = res.data
      })

    },
    ToDoCheck() {
      // if (this.list.length > 1 || this.list.length == 0) {
      //   this.$modal.msgError('请选择一条记录信息！')
      //   return
      // }
      this.VisibleCheck = true

    },
    cancelCheck() {
      this.VisibleCheck = false
    },
    submitCheck() {
      var check = []
      this.ids.forEach(id => {
        check.push({ businessId: id, ...this.formCheck })
      })
      SampleTalentApplyCheck(check).then(response => {
        if (response.code == 200) {
          this.$modal.msgSuccess('申请成功')
          this.VisibleCheck = false
          this.getList()
        }
      })
    },

    chatReturn() {
      if (this.list.length > 1 || this.list.length == 0) {
        this.$modal.msgError('请选择一条记录信息！')
        return
      }
      returnApply(this.list[0]).then(response => {
        if (response.code == 200) {
          this.$modal.msgSuccess('申请成功')
          this.getList()
        }
      })

    },

    chatReturn() {
      if (this.list.length > 1 || this.list.length == 0) {
        this.$modal.msgError('请选择一条记录信息！')
        return
      }
      returnApply(this.list[0]).then(response => {
        if (response.code == 200) {
          this.$modal.msgSuccess('申请成功')
          this.getList()
        }
      })

    },
    //添加颜色列表获得焦点
    onFocus() {
      this.getData()
      // if (!this.form.colorProperty) {
      //     this.$selectRef.value.blur() //就是这一句，
      // }
    },




    /* 获取颜色列表 */
    getData(key) {
      console.log(JSON.stringify(key));
      // this.loading = true;
      // return
      productNoColorLike({ productNo: this.form.productNo, color: key }).then((res) => {
        // this.loading = false;
        this.ColorLike = res.data;
        console.log(JSON.stringify(this.ColorLike));
      });
    },

    /* 获取货号列表 */
    getDatas(key) {
      console.log(JSON.stringify(key));
      this.loading = true;
      // return
      productNoLike(key).then((res) => {
        this.loading = false;
        this.options = res.data;
        console.log(JSON.stringify(this.options));
      });
    },
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    //点击某一行
    t(row, column, cell, event) {
      console.log(row, column, cell, event);
      this.handleUpdate(row)
    },
    /** 查询样衣申请记录列表 */
    getList() {
      this.loading = true;
      listSampleApply(this.queryParams).then(response => {
        this.sampleApplyList = response.rows;
        console.log(JSON.stringify(this.sampleApplyList));
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        sampleTalentInfoId: null,
        sampleTalentCooperateId: null,
        sampleTalentCooperateType: null,
        templateId: null,
        templateSecondryId: null,
        templateSizeId: null,
        contactId: null,
        isReturn: null,
        remark: null,
        onlineNumber: null,
        subOrderNumber: null,
        buyerAccount: null,
        paymentOrderNumber: null,
        paymentMethod: null,
        freight: null,
        payableAmount: null,
        fixedLine: null,
        zipCode: null,
        styleMainImage: null,
        productCode: null,
        productNum: null,
        productName: null,
        productPricing: null,
        productCost: null,
        productSettlment: null,
        productBatch: null,
        manufactureDate: null,
        expressCompany: null,
        expressNumber: null,
        deliveryTime: null,
        salesman: null,
        offlineNotes: null,
        applyStatus: null,
        isDelete: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        returnPhone: null,
        returnRecipient: null,
        returnAddress: null,
        returnContactId: null,
        returnExpressPickupCode: null,
        returnExpressNumber: null,
        returnDate: null,

      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;

      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams = {}
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
      this.list = selection.map(item => item)
      // var returnAddress = selection.map(item => item.returnAddress)
      // this.returnAddress = Array.from(new Set(returnAddress))
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加样衣申请记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getSampleApply(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改样衣申请记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateSampleApply(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addSampleApply(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除样衣申请记录编号为"' + ids + '"的数据项？').then(function () {
        return delSampleApply(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('product/sampleApply/export', {
        ...this.queryParams
      }, `sampleApply_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style lang="scss" scoped>
.el-dialog-div {
  height: 70vh;
  overflow-x: hidden;
}
</style>